home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / New System Software Extensions / QuickDraw™ GX v1.0ß2 / Sample Code / Printing Samples / Extensions… / Additions Source / RenderPageMessage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-31  |  3.1 KB  |  107 lines  |  [TEXT/MPS ]

  1. /* ------------------------------------------------------------------------------
  2.  
  3.     FILENAME
  4.         RenderPageMessage.c
  5.  
  6.     DESCRIPTION
  7.         This file contains the message procedure that will be invoked when the Printing Manager
  8.         issues the RenderPage message.  The routine which is called is RenderPageMessageProc.
  9.         Depending upon the effects the user selected in the Addition's Print dialog panel, 
  10.         RenderPageMessageProc will invoke routines in the Additions.c file to produce the
  11.         desired effects.
  12.  
  13.     COPYRIGHT
  14.         Copyright Apple Computer, Inc. 1991
  15.         All rights reserved. 
  16.     
  17.     INTERFACE ROUTINES
  18.         RenderPageMessageProc
  19.  
  20.     MODIFICATION HISTORY
  21.         05/15/91            ALA                Initial Implementation
  22.  
  23.  
  24. ------------------------------------------------------------------------------- */
  25.  
  26.  
  27. #include <Types.h>
  28. #include <Quickdraw.h>
  29. #include <Memory.h>
  30. #include <Resources.h>
  31. #include <Dialogs.h>
  32. #include <TextEdit.h>
  33. #include <OSUtils.h>
  34. #include <Packages.h>
  35. #include <ToolUtils.h>
  36. #include <Menus.h>
  37. #include <String.h>
  38. #include <Strings.h>
  39. #include <Printing.h>
  40.  
  41. #include <graphics routines.h>
  42. #include <graphics libraries.h>
  43. #include <Font Library.h>
  44.  
  45. #include <Collections.h>
  46. #include <Messages.h>
  47.  
  48. #include    <PrintingManager.h>
  49. #include    <PrintingMessages.h>
  50.  
  51. #include "Utilities.h"
  52. #include "Additions.h"
  53.  
  54.  
  55. /*================================== MESSAGE INTERFACE ROUTINES ==================================*/
  56.  
  57.  
  58. /* ===== RenderPageMessageProc =====
  59.  
  60.     RenderPageMessageProc is the extension's routine which will be invoked when Printing issues a 
  61.     renderPage message.  This routine checks to see if a serial number should be added
  62.     to the page. If so, it will call SerializeCopies to generate and add a serial number shape
  63.     to the page.  Regardless of whether a serial number is added to the page, the routine calls
  64.     Forward_RenderPage to render the page.
  65. */
  66. OSErr RenderPageMessageProc(            //    (out)    Error code
  67.     gxFormat                theFormat,            //    (in)    Format reference for the page being rendered
  68.     gxShape                thePage,                //    (in)    The page shape being rendered
  69.     gxPageInfoRecord    *pageInfo,            //    (in)    page info. describing the page
  70.     void                    *imageData)            //    (in)    image data generated
  71. {
  72.     OSErr                         anErr = noErr;
  73.     Collection                    jobCollection;
  74.     AdditionsCollection        additionsConfig;
  75.     
  76.     /* Get reference to the print Job's collection */
  77.     jobCollection = GXGetJobCollection(GXGetJob());
  78.     
  79.     /* Fetch a handle to the Additions's collection we created at Print dialog time */
  80.     anErr = GetCollectionItem (jobCollection,
  81.                                         kAdditionsCollectionType,
  82.                                         gxPrintingTagID,
  83.                                         nil,
  84.                                         &additionsConfig);
  85.     if (anErr == noErr)
  86.     {
  87.         /* If we're serializing copies, add the serial number to the page shape */
  88.         if (additionsConfig.serializeCopies)
  89.         {
  90.             SerializeCopies(    thePage, 
  91.                                     theFormat, 
  92.                                     pageInfo->copyNum, 
  93.                                     &pageInfo->pageChanged, 
  94.                                     additionsConfig.nextEndSerialNum,
  95.                                     GetCopiesFromJob(jobCollection));
  96.         }
  97.     }
  98.     else    // T => no config; don't do anything
  99.         anErr = noErr;
  100.  
  101.     /* Pass the render page message on to others */
  102.     anErr = Forward_GXRenderPage (theFormat, thePage, pageInfo, imageData);
  103.  
  104.     return(anErr);
  105. }
  106. /* RenderPageMessageProc */
  107.